//
//  ReadViewController.m
//  NeteaseNews
//
//  Created by liutaifeng on 16/4/13.
//  Copyright © 2016年 liutaifeng. All rights reserved.
//

#import "ReadViewController.h"
#import "LTFReadView.h"
#import "ReadContentViewController.h"
#import "ReadBookMarkViewController.h"
#define WIDTH self.view.frame.size.width
@interface ReadViewController ()
<
 LTFReadViewDelegate
>

@property (nonatomic, retain) UIView *myView;
@property (nonatomic, retain) NSString *string;
@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UILabel *label;
@end

@implementation ReadViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
//    self.automaticallyAdjustsScrollViewInsets = NO;
    [self createView];
    
}
- (void)createView {
    
    self.myView = [[[UIView alloc] initWithFrame:CGRectMake(0, 24, self.view.frame.size.width, 40)] autorelease];
    self.myView.backgroundColor = [UIColor redColor];
    
    
    LTFReadView *readView = [[LTFReadView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64)];
    [self.view addSubview:readView];
    [readView release];
    readView.delegate = self;
    //右上角的按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setImage:[UIImage imageNamed:@"jiaru.png"] forState:UIControlStateNormal];
    button.frame = CGRectMake(WIDTH - 40, 0, 40, 40);
    button.tintColor = [UIColor whiteColor];
    [button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.myView addSubview:button];
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 100, 40)];
    _label.font = [UIFont systemFontOfSize:18];
    [_myView addSubview:_label];
    //_label.center = CGPointMake(_myView.center.x, 0);
    _label.text = @"推荐阅读";
    _label.textColor = [UIColor whiteColor];

}

- (void)click:(UIButton *)button {
    ReadBookMarkViewController *bookMarkVC = [[ReadBookMarkViewController alloc] init];
    [self.navigationController pushViewController:bookMarkVC animated:YES];
    [bookMarkVC release];
}
- (void)viewWillAppear:(BOOL)animated {
    [self.navigationController.view addSubview:self.myView];
    UITableView *tableView = [self.view viewWithTag:1003];
    [tableView reloadData];
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.myView removeFromSuperview];
}

- (void)sendReadDocid:(NSString *)readDocid {
    
    //NSLog(@"%@", readDocid);
    ReadContentViewController *readContentVC = [[ReadContentViewController alloc] init];
    [self.navigationController pushViewController:readContentVC animated:YES];
    readContentVC.string = readDocid;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
